package com.zyit.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zyit.dto.HospitalSetDto;
import com.zyit.pojo.HospitalSet;
import com.zyit.service.HospitalService;
import com.zyit.service.HospitalSetService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "医院设置")
@RestController
@RequestMapping("/admin/hosp")
public class HospitalSetController {
    @Autowired
    private HospitalSetService hospitalSetService;

    @Operation(summary = "查询所有医院设置信息")
    @GetMapping
    public List<HospitalSet> findAll() {
        List<HospitalSet> list = hospitalSetService.findAll();
        return list;
    }

    @Operation(summary = "分页和条件查询")
    @PostMapping("/page")
    public Page findPage(@RequestBody HospitalSetDto hospitalSetDto) {
        return hospitalSetService.findPage(hospitalSetDto);
    }

    @Operation(summary = "根据id删除医院")
    @DeleteMapping("{id}")
    public int removeById(@PathVariable Long id){
        return hospitalSetService.del(id);
    }

    @Operation(summary = "修改医院设置")
    @PutMapping
    public int edit(@RequestBody HospitalSet hospitalSet) {
        return hospitalSetService.edit(hospitalSet);
    }

    @Operation(summary = "添加医院设置")
    @PostMapping
    public int add(@RequestBody HospitalSet hospitalSet) {
        return hospitalSetService.add(hospitalSet);
    }

    @Operation(summary = "锁定或解除锁定")
    @PostMapping("/lock/{id}")
    public int lockHandler(@PathVariable Long id) {
        return hospitalSetService.lock(id);
    }

    @Operation(summary = "批量删除")
    @PostMapping("/delBatch")
    public int delBatch(@RequestBody List<Long> ids) {
        return hospitalSetService.delBatch(ids);
    }
}
